<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

function calc($size,$digits=2){ 
	if (!$size) {
		return '0B';
	}
  $unit= array('','K','M','G','T','P');
  $base= 1024;
  $i = floor(log($size,$base));
  $n = count($unit);
  if($i >= $n){
    $i=$n-1;
  }
  return round($size/pow($base,$i),$digits).' '.$unit[$i] . 'B';
}

/*
 * 密码加密
 */
function md5_password($value){
    return md5(sha1($value).config('app.passwd_key'));
}

function repeat($value,$str = '——'){
    return str_repeat($str, $value);
}
